﻿using Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace RedisHelper.Notify
{
    public class LatestMessage
    {
        /// <summary>
        /// 获取最新消息数
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public long GetLatestMessageCount(int uid)
        {
            using (RedisHelper rh = new RedisHelper())
            {
                return rh.GetDatabase(6).ListLength(StaticConfigRidesName.LatestMessage_List(uid));
            }
        }

        /// <summary>
        /// 删除最新消息
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public bool DelLatestMessage(int uid)
        {
            try
            {
                using (RedisHelper rh = new RedisHelper())
                {
                    rh.GetDatabase(6).KeyDelete(StaticConfigRidesName.LatestMessage_List(uid));
                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
